/**
 * @file 发送请求
 * @author LiQun
 * @date 2021/11/28
 */
const request = require('request');
const {getPort} = require('./utils');


const get = function (url, params) {
  const host = 'http://127.0.0.1';
  const port = getPort();
  const baseUrl = `${host}:${port}`;
  return new Promise((resolve, reject) => {
    request(baseUrl + url, function (error, response, body) {
      if (error) {
        reject(error);
        return;
      }
      const result = JSON.parse(body)
      // const qrcode = result.qrcode;
      resolve(result);
    });
  })
}
// get('http://127.0.0.1:41037/v2/login?qr-format=terminal&qr-size=small&result-output=/Users/gemini/Documents/workspace/cli/link-cli/cache/result.json')
module.exports.get = get
